package com.huilian.iotbox.admin.wap.controller;

import com.huilian.iotbox.admin.wap.service.OrderItemService;
import com.huilian.iotbox.data.common.ServerResponse;
import com.huilian.iotbox.data.controller.BaseController;
import com.huilian.iotbox.data.dto.OrderDto;
import com.huilian.iotbox.data.dto.OrderItemDto;
import com.huilian.iotbox.data.vo.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author LinYinDong
 * @date 2023/12/23 11:02
 */
@RestController
@RequestMapping("/api/orderItem")
public class OrderItemController extends UserInfoController {
    @Autowired
    private OrderItemService orderItemService;

    @GetMapping("/findOrderItemByOrderIdList")
    public ServerResponse findOrderItemByOrderIdList(OrderItemDto orderItemDto, HttpServletRequest request) {
        UserInfo userInfo = super.getLoginUserInfo(request);
        if (ObjectUtils.isEmpty(userInfo)) {
            return ServerResponse.createByErrorMessage("获取商户信息失败");
        }
        orderItemDto.setUserInfo(userInfo);
        return orderItemService.findOrderItemByOrderIdList(orderItemDto);
    }
}
